package com.ls.blog.controller;



import com.ls.blog.service.OssService;
import com.ls.blog.utils.R;
import com.ls.blog.utils.RedisUtil;
import com.ls.blog.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author xppll
 * @date 2021/12/2 19:36
 */
@RestController
@RequestMapping("upload")
@Api(tags = "上传模块")
public class OssController {

    @Autowired
    private OssService ossService;

    @Autowired
    private RedisUtil redisUtil;

    @PostMapping
    @ApiOperation(value = "图片上传")
    public Result<String> uploadOssFile(MultipartFile file){
        //获取上传文件 MultipartFile
        //返回图片在oss上的路径
        String url = ossService.uploadFileAvatar(file);
        return R.ok(url);
    }

}
